{% macro print_arguments(data) %}
    {% for item in data %}
        {{ item }}="{{ data[item] }}"
    {% endfor %}
{% endmacro %}

{% macro side_tree_leaf(data) %}
    <div class="tree-item tree-leaf js-item js-leaf {{ data.class }}">
        {% if data.is_active %}
            <div class="tree-item-title tree-leaf-title js-item-title js-leaf-title is_active {{ data.title_class }}">
                <div class="marker"></div>
                <div class="text">{{ data.title }}</div>
            </div>
        {% else %}
            <a href="{{ data.url }}"
               class="tree-item-title tree-leaf-title js-item-title js-leaf-title {{ data.title_class }}"
                    {% if data.title_arguments %}{{ print_arguments(data.title_arguments) }}{% endif %}
            >
                <span class="marker"></span>
                <span class="text">{{ data.title }}</span>
            </a>
        {% endif %}
    </div>
{% endmacro %}

{% macro side_tree_branch(data) %}
    <div class="tree-item tree-branch js-item js-branch _opened"
         data-id="{{ data.title }}">

        <div class="tree-item-title tree-branch-title js-item-title js-branch-title is_active">
            <div class="marker"></div>
            <div class="text">{{ data.title }}</div>
        </div>

        {% for item in data.content %}
            {% if item.content %}
                {{ side_tree_branch(item) }}
            {% else %}
                {{ side_tree_leaf(item) }}
            {% endif %}
        {% endfor %}
    </div>
{% endmacro %}

{% macro side_tree_nav(nav) %}
    <nav class="side-tree-nav">
        {% for category in nav %}
            {{ side_tree_branch(category) }}
        {% endfor %}
    </nav>
{% endmacro %}